let {DataTypes, Sequelize} = require("sequelize");
let {getInstance} = require("../utils/mysql-client");

let model = getInstance('bigScreen').define('task_admin', {
    id: {type: DataTypes.INTEGER, autoIncrement: true, primaryKey: true},
    //用户标识
    userId: DataTypes.BIGINT(20),
    //用户名称
    name: DataTypes.STRING,
    //任务
    task: DataTypes.TEXT,
    //频率
    frequency: DataTypes.INTEGER,
    //图表
    chart: DataTypes.STRING,
    line: DataTypes.STRING,
    //切换时间
    switchTime: DataTypes.INTEGER,
    createTime: {type: 'TIMESTAMP', defaultValue: Sequelize.literal('CURRENT_TIMESTAMP')},
    updateTime: {type: 'TIMESTAMP', defaultValue: Sequelize.literal('CURRENT_TIMESTAMP')}
}, {
    freezeTableName: true,
    createdAt: false,
    updatedAt: false,
    //索引
    indexes: [
        {fields: ['userId']},
        {fields: ['name']},
        {fields: ['createTime']},
        {fields: ['updateTime']},
    ]
});
//创建表，false没有直接创建，true则是删除原有表和数据，再创建
model.sync({
    force: false,
});
module.exports = model;